﻿
using System;
using System.Drawing;
namespace Minecraft_2D.Blocks
{
    class Grass : Bloc
    {
        #region Attributs
        #endregion

        #region Constructeur
        public Grass(int percent)
            : base("Grass", Properties.Resources.Grass, true, percent)
        {
        }
        #endregion

        #region Proprietes
        #endregion

        #region Methodes
        public override TypeBloc OnNew(Block bloc)
        {
            Random random = new Random();
            int rnd = random.Next(BlocSet.GetSingleton()[TypeBloc.Wood].Percent + BlocSet.GetSingleton()[TypeBloc.Air].Percent);

            if (bloc.Top != TypeBloc.Air)
                return BlocSet.GetSingleton()[TypeBloc.Dirt].OnNew(bloc);

            if (rnd < BlocSet.GetSingleton()[TypeBloc.Wood].Percent)
                bloc.Top.Type=BlocSet.GetSingleton()[TypeBloc.Wood].OnNew(bloc);

            if (bloc.Bottom == TypeBloc.Grass)
                bloc.Bottom.Type=BlocSet.GetSingleton()[TypeBloc.Dirt].OnNew(bloc);
            return TypeBloc.Grass;
        }
        #endregion
    }
}
